package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.bean.FeedBackTypeBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.FeedBackActivity;

import java.util.List;


public class FeedBackActivityPresenter extends BasePresenter<FeedBackActivity> {

    public void getFeedBackType() {
        httpService.getFeedBackType()
                .execute(new JsonCallBack<HttpData<List<FeedBackTypeBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<FeedBackTypeBean>>> response) {
                        HttpData<List<FeedBackTypeBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateFeedBackType(httpData.getData());
                        }
                    }
                });
    }

    public void feedBack(String type, String desc, String tel) {
        httpService.feedBack(type, desc, tel)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.feedBackSuccess();
                        }
                    }
                });
    }
}
